<template>
    <div>
      <el-row style="margin-top:22px;">
        <el-col :span="6">
          中联订单号：
        </el-col>
      </el-row>
      <el-row style="margin:0 0 22px 0">
        <el-col :span="22">
          <el-input type="textarea" v-model="orderId" placeholder="请输入中联订单号(注：以 逗号，空格，回车分割)">
          </el-input>
        </el-col>
        <el-col :span="2" style="text-align: center">
          <el-button type="primary" style="margin-top: 20px" :loading="loadingFlag" @click="search">拉取</el-button>
        </el-col>
      </el-row>
      <el-table
        id="handle-position"
        :data="tableData"
        stripe
        border
        :height="height"
        style="width: 100%">
        <el-table-column prop="sysOrderNo" label="订单号" >

        </el-table-column>
        <el-table-column label="拉取状态">
            <template slot-scope="scope">
              <el-tag type="danger" v-if="scope.row.result === '拉取失败' || scope.row.result === '不存在此订单号'">{{scope.row.result}}</el-tag>
              <el-tag type="success" v-else>{{scope.row.result}}</el-tag>
            </template>
        </el-table-column>
      </el-table>
    </div>
</template>

<script>
  import * as handleAPI from '@/api/handle'
  export default {
    name: 'oneOrder',
    data() {
      return {
        orderId: '',
        tableData: [],
        loadingFlag: false,
        height: 200
      }
    },
    mounted() {
      const appMainHeight = document.getElementById('app').offsetHeight
      this.height = appMainHeight - 220
    },
    methods: {
      search() {
        const that = this
        if (that.orderId) {
          that.orderId = that.orderId.replace('/[,\n\s]/g', ',')
          that.loadingFlag = true
          handleAPI.getOneOrder({ sysOrderNo: that.orderId }).then(res => {
            if (res.code === 0) {
              that.tableData = res.data
              that.loadingFlag = false
            }
          })
        } else {
          that.$message.info('请输入！')
        }
      }
    }

  }
</script>

<style scoped>
</style>
